//
//  ByChaseNumberTitleCell.m
//  caipiao_ios
//
//  Created by mc on 2018/8/13.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByChaseNumberTitleCell.h"
#import "ByBetTitleValueView.h"

@implementation ByChaseNumberTitleCell

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByChaseNumberTitleCell";
    ByChaseNumberTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        self.contentView.backgroundColor = BY_BACKGROUND_COLOR;
       
    }
    return self;
}


- (void)initViews{
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    UIView *backgroundView = [[UIView alloc] init];
    [self.contentView addSubview:backgroundView];
    [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.top.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView).offset(0);
    }];
    backgroundView.layer.cornerRadius = 10;
    backgroundView.backgroundColor = [UIColor whiteColor];
    
    
    CGFloat top = 17;
    for (int i = 0; i < 4; i++) {
        ByBetTitleValueView *valueView = [[ByBetTitleValueView alloc] init];
        [backgroundView addSubview:valueView];
        [valueView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(backgroundView).offset(0);
            make.right.equalTo(backgroundView).offset(0);
            make.top.equalTo(backgroundView).offset(top + i * 30);
            make.height.mas_equalTo(@30);
        }];
        
        if (i == 0) {
            valueView.titleLabel.text = @"彩    种:";
            valueView.valueLabel.text = _netModel.alias_name;
        }else if (i == 1){
            valueView.titleLabel.text = @"追号类型:";
            valueView.valueLabel.text = _netModel.is_rand.integerValue == 1 ? @"随机追号":@"固定追号";
        }else if (i == 2){
            valueView.titleLabel.text = @"追号金额:";
            valueView.valueLabel.text = [NSString stringWithFormat:@"%@元",_netModel.amount];
        }else if (i == 3){
            valueView.titleLabel.text = @"追号期数:";
            valueView.valueLabel.text =  [NSString stringWithFormat:@"剩%ld期/共%@期",_netModel.push_number.integerValue - _netModel.use_number.integerValue,_netModel.push_number];
        }
    }
    
}

- (void)setNetModel:(ByNetModel *)netModel{
    _netModel = netModel;
     [self initViews];
    
}

@end
